<template>
    <div>
        <h1>添加</h1>
        <table>
            <tbody>
                <tr>
                    <td>姓名</td>
                    <td>
                        <input type="text" v-model="data.name">
                    </td>
                </tr>
                <tr>
                    <td>手机号</td>
                    <td>
                        <input type="text" v-model="data.phone">
                    </td>
                </tr>
                <tr>
                    <td>账号</td>
                    <td>
                        <input type="text" v-model="data.number">
                    </td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td>
                        <input type="password" v-model="data.pwd">
                    </td>
                </tr>
                <tr>
                    <td>所属角色</td>
                    <td>
                        <input type="text" v-model="data.nName">
                    </td>
                </tr>
                <tr>
                    <td>创建人</td>
                    <td>
                        <input type="text" v-model="data.peoo">
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="button" value="添加" @click="add">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import axios from 'axios';

const add=()=>{
    axios.post("https://localhost:7249/api/User/Add",data.value).then(res=>{
        if(res.data>0){
            alert("添加成功")
            location.href="/Show"
        }
        else{
            alert("添加失败")
        }
    })
}

const data=ref({
  "id": 0,
  "name": "",
  "phone": "",
  "number": "",
  "pwd": "",
  "nName": "",
  "peoo": ""
})
</script>

<style scoped>

</style>